////////////////////////////////////////////////////////////////////////////
//
//  CryEngine Source File.
//  Copyright (C), Crytek Studios, 2001-2007.
// -------------------------------------------------------------------------
//  File name:   MemoryManager.h
//  Version:     v1.00
//  Created:     27/7/2007 by Timur.
// -------------------------------------------------------------------------
//  History:
//
////////////////////////////////////////////////////////////////////////////

#ifndef __MemoryManager_h__
#define __MemoryManager_h__
#pragma once

#include "ISystem.h"

//////////////////////////////////////////////////////////////////////////
// Class that implements IMemoryManager interface.
//////////////////////////////////////////////////////////////////////////
#ifndef MEMMAN_STATIC
class CCryMemoryManager : public IMemoryManager
{
public:
	// Singleton
	static CCryMemoryManager* GetInstance();

	//////////////////////////////////////////////////////////////////////////
	virtual bool GetProcessMemInfo( SProcessMemInfo &minfo );
	virtual void FakeAllocation( long size );

	virtual void InitialiseLevelHeap();

	virtual void SwitchToLevelHeap();
	virtual void SwitchToGlobalHeap();

	virtual int LocalSwitchToGlobalHeap();
	virtual int LocalSwitchToLevelHeap();
	virtual void LocalSwitchToHeap(int heap);

	virtual bool GetLevelHeapViolationState(bool& usingLevelHeap, size_t& numAllocs, size_t& allocSize);

	virtual HeapHandle TraceDefineHeap( const char *heapName,size_t size,const void* pBase );
	virtual void TraceHeapAlloc( HeapHandle heap,void* mem, size_t size, size_t blockSize, const char *sUsage,const char *sNameHint=0 );
	virtual void TraceHeapFree( HeapHandle heap,void* mem, size_t blockSize );
	virtual void TraceHeapSetColor( uint32 color );
	virtual uint32 TraceHeapGetColor();
	virtual void TraceHeapSetLabel( const char *sLabel );

	virtual struct IMemReplay* GetIMemReplay();
	virtual ICustomMemoryHeap* const CreateCustomMemoryHeapInstance(bool const bCanUseGPUMemory);
	virtual IGeneralMemoryHeap* CreateGeneralExpandingMemoryHeap(size_t upperLimit, size_t reserveSize, const char* sUsage);
	virtual IGeneralMemoryHeap* CreateGeneralMemoryHeap(void* base, size_t sz,const char *sUsage);

	virtual IPageMappingHeap* CreatePageMappingHeap(size_t addressSpace, const char* sName);
};
#else
typedef IMemoryManager CCryMemoryManager;
#endif

#endif // __MemoryManager_h__